home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Game / C / Cheese Toast 1.01.sit / CheeseToast ƒ / Source / UtilFuncs.c < prev    next >
MacBinary  |  1993-06-03  |  2.5 KB  |  [TEXT/KAHL]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: MacBinary (archive/macBinary).

You can browse this item here: UtilFuncs.c

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Thu Jun 3 10:55:28 1993, modified Thu Jun 3 10:55:28 1993, creator Think C, type ASCII, 1858 bytes "UtilFuncs.c" , at 0x7c2 402 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KAHL]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0b 55 74 69 6c 46 75 | 6e 63 73 2e 63 00 00 00 |..UtilFu|ncs.c...|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 41 48 | 4c 01 00 00 00 00 00 00 |.TEXTKAH|L.......|
|00000050| 00 00 00 00 00 07 42 00 | 00 01 92 a8 33 c1 60 a8 |......B.|....3.`.|
|00000060| 33 c1 60 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |3.`.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 97 19 00 00 |........|........|
|00000080| 2f 2f 20 55 74 69 6c 66 | 75 6e 63 73 2e 63 0d 23 |// Utilf|uncs.c.#|
|00000090| 69 6e 63 6c 75 64 65 20 | 3c 73 74 64 61 72 67 2e |include |<stdarg.|
|000000a0| 68 3e 0d 23 69 6e 63 6c | 75 64 65 20 3c 73 74 72 |h>.#incl|ude <str|
|000000b0| 69 6e 67 2e 68 3e 0d 0d | 73 68 6f 72 74 20 4d 79 |ing.h>..|short My|
|000000c0| 52 61 6e 64 6f 6d 28 73 | 68 6f 72 74 20 6c 69 6d |Random(s|hort lim|
|000000d0| 69 74 29 0d 7b 0d 09 75 | 6e 73 69 67 6e 65 64 20 |it).{..u|nsigned |
|000000e0| 6c 6f 6e 67 20 72 3b 0d | 09 72 20 3d 20 28 75 6e |long r;.|.r = (un|
|000000f0| 73 69 67 6e 65 64 29 20 | 52 61 6e 64 6f 6d 28 29 |signed) |Random()|
|00000100| 3b 0d 09 72 20 3d 20 28 | 72 2a 28 6c 6f 6e 67 29 |;..r = (|r*(long)|
|00000110| 6c 69 6d 69 74 29 2f 36 | 35 35 33 36 4c 3b 0d 09 |limit)/6|5536L;..|
|00000120| 72 65 74 75 72 6e 20 28 | 73 68 6f 72 74 29 20 72 |return (|short) r|
|00000130| 3b 0d 7d 0d 0d 76 6f 69 | 64 20 47 65 74 49 6e 70 |;.}..voi|d GetInp|
|00000140| 75 74 46 69 6c 65 53 70 | 65 63 28 53 46 52 65 70 |utFileSp|ec(SFRep|
|00000150| 6c 79 20 2a 74 68 65 52 | 65 70 6c 79 2c 53 74 72 |ly *theR|eply,Str|
|00000160| 69 6e 67 50 74 72 20 70 | 72 6f 6d 70 74 2c 6c 6f |ingPtr p|rompt,lo|
|00000170| 6e 67 20 74 79 70 65 29 | 0d 7b 0d 09 50 6f 69 6e |ng type)|.{..Poin|
|00000180| 74 09 73 66 4c 6f 63 3b | 0d 09 73 68 6f 72 74 09 |t.sfLoc;|..short.|
|00000190| 6e 62 72 54 79 70 65 73 | 3b 0d 09 53 46 54 79 70 |nbrTypes|;..SFTyp|
|000001a0| 65 4c 69 73 74 09 74 68 | 65 4c 69 73 74 3b 0d 0d |eList.th|eList;..|
|000001b0| 09 69 66 20 28 74 79 70 | 65 29 20 7b 0d 09 09 6e |.if (typ|e) {...n|
|000001c0| 62 72 54 79 70 65 73 20 | 3d 20 31 3b 0d 09 09 74 |brTypes |= 1;...t|
|000001d0| 68 65 4c 69 73 74 5b 30 | 5d 20 3d 20 74 79 70 65 |heList[0|] = type|
|000001e0| 3b 0d 09 7d 0d 09 65 6c | 73 65 20 7b 0d 09 09 6e |;..}..el|se {...n|
|000001f0| 62 72 54 79 70 65 73 20 | 3d 20 2d 31 3b 0d 09 7d |brTypes |= -1;..}|
|00000200| 0d 0d 09 73 66 4c 6f 63 | 2e 68 20 3d 20 2d 31 3b |...sfLoc|.h = -1;|
|00000210| 0d 09 73 66 4c 6f 63 2e | 76 20 3d 20 2d 31 3b 0d |..sfLoc.|v = -1;.|
|00000220| 09 53 46 47 65 74 46 69 | 6c 65 28 73 66 4c 6f 63 |.SFGetFi|le(sfLoc|
|00000230| 2c 20 70 72 6f 6d 70 74 | 2c 20 4e 55 4c 4c 2c 20 |, prompt|, NULL, |
|00000240| 6e 62 72 54 79 70 65 73 | 2c 20 74 68 65 4c 69 73 |nbrTypes|, theLis|
|00000250| 74 2c 0d 09 09 09 09 4e | 55 4c 4c 2c 20 74 68 65 |t,.....N|ULL, the|
|00000260| 52 65 70 6c 79 29 3b 0d | 7d 0d 0d 76 6f 69 64 20 |Reply);.|}..void |
|00000270| 47 65 74 4f 75 74 70 75 | 74 46 69 6c 65 53 70 65 |GetOutpu|tFileSpe|
|00000280| 63 28 53 46 52 65 70 6c | 79 20 2a 74 68 65 52 65 |c(SFRepl|y *theRe|
|00000290| 70 6c 79 2c 53 74 72 69 | 6e 67 50 74 72 20 70 72 |ply,Stri|ngPtr pr|
|000002a0| 6f 6d 70 74 2c 53 74 72 | 69 6e 67 50 74 72 20 64 |ompt,Str|ingPtr d|
|000002b0| 65 66 4e 61 6d 65 29 0d | 7b 0d 09 50 6f 69 6e 74 |efName).|{..Point|
|000002c0| 09 73 66 4c 6f 63 3b 0d | 0d 0d 09 73 66 4c 6f 63 |.sfLoc;.|...sfLoc|
|000002d0| 2e 68 20 3d 20 2d 31 3b | 0d 09 73 66 4c 6f 63 2e |.h = -1;|..sfLoc.|
|000002e0| 76 20 3d 20 2d 31 3b 0d | 0d 09 53 46 50 75 74 46 |v = -1;.|..SFPutF|
|000002f0| 69 6c 65 28 73 66 4c 6f | 63 2c 20 70 72 6f 6d 70 |ile(sfLo|c, promp|
|00000300| 74 2c 20 64 65 66 4e 61 | 6d 65 2c 20 4e 55 4c 4c |t, defNa|me, NULL|
|00000310| 2c 20 74 68 65 52 65 70 | 6c 79 29 3b 0d 0d 7d 0d |, theRep|ly);..}.|
|00000320| 0d 0d 69 6e 74 20 4d 79 | 46 47 65 74 73 28 73 68 |..int My|FGets(sh|
|00000330| 6f 72 74 20 72 65 66 4e | 75 6d 2c 20 63 68 61 72 |ort refN|um, char|
|00000340| 20 2a 62 75 66 29 0d 7b | 0d 0d 23 64 65 66 69 6e | *buf).{|..#defin|
|00000350| 65 20 45 4f 4c 09 09 09 | 31 33 0d 23 64 65 66 69 |e EOL...|13.#defi|
|00000360| 6e 65 20 4d 61 78 42 75 | 66 53 69 7a 65 09 32 35 |ne MaxBu|fSize.25|
|00000370| 36 0d 0d 09 49 4f 50 61 | 72 61 6d 09 70 62 3b 0d |6...IOPa|ram.pb;.|
|00000380| 09 4f 53 45 72 72 09 6f | 65 3b 0d 0d 09 70 62 2e |.OSErr.o|e;...pb.|
|00000390| 69 6f 43 6f 6d 70 6c 65 | 74 69 6f 6e 20 3d 20 4e |ioComple|tion = N|
|000003a0| 55 4c 4c 3b 0d 09 70 62 | 2e 69 6f 52 65 66 4e 75 |ULL;..pb|.ioRefNu|
|000003b0| 6d 20 3d 20 72 65 66 4e | 75 6d 3b 0d 09 70 62 2e |m = refN|um;..pb.|
|000003c0| 69 6f 42 75 66 66 65 72 | 20 3d 20 28 50 74 72 29 |ioBuffer| = (Ptr)|
|000003d0| 20 62 75 66 3b 0d 09 70 | 62 2e 69 6f 52 65 71 43 | buf;..p|b.ioReqC|
|000003e0| 6f 75 6e 74 20 3d 20 4d | 61 78 42 75 66 53 69 7a |ount = M|axBufSiz|
|000003f0| 65 3b 0d 09 70 62 2e 69 | 6f 50 6f 73 4d 6f 64 65 |e;..pb.i|oPosMode|
|00000400| 20 3d 20 66 73 41 74 4d | 61 72 6b 20 7c 20 30 78 | = fsAtM|ark | 0x|
|00000410| 38 30 20 7c 20 28 27 5c | 72 27 20 3c 3c 20 38 29 |80 | ('\|r' << 8)|
|00000420| 3b 0d 09 70 62 2e 69 6f | 50 6f 73 4f 66 66 73 65 |;..pb.io|PosOffse|
|00000430| 74 20 3d 20 30 3b 0d 0d | 09 6f 65 20 3d 20 50 42 |t = 0;..|.oe = PB|
|00000440| 52 65 61 64 28 28 50 61 | 72 6d 42 6c 6b 50 74 72 |Read((Pa|rmBlkPtr|
|00000450| 29 20 26 70 62 2c 20 66 | 61 6c 73 65 29 3b 0d 09 |) &pb, f|alse);..|
|00000460| 69 66 20 28 6f 65 20 3d | 3d 20 6e 6f 45 72 72 20 |if (oe =|= noErr |
|00000470| 7c 7c 20 6f 65 20 3d 3d | 20 65 6f 66 45 72 72 20 ||| oe ==| eofErr |
|00000480| 26 26 20 70 62 2e 69 6f | 41 63 74 43 6f 75 6e 74 |&& pb.io|ActCount|
|00000490| 20 3e 20 30 29 20 7b 0d | 09 09 62 75 66 5b 70 62 | > 0) {.|..buf[pb|
|000004a0| 2e 69 6f 41 63 74 43 6f | 75 6e 74 5d 20 3d 20 30 |.ioActCo|unt] = 0|
|000004b0| 3b 09 2f 2f 20 41 64 64 | 20 61 20 6e 75 6c 20 74 |;.// Add| a nul t|
|000004c0| 6f 20 74 68 65 20 65 6e | 64 0d 09 09 72 65 74 75 |o the en|d...retu|
|000004d0| 72 6e 20 31 3b 0d 09 7d | 0d 09 65 6c 73 65 0d 09 |rn 1;..}|..else..|
|000004e0| 09 72 65 74 75 72 6e 20 | 30 3b 0d 7d 0d 0d 76 6f |.return |0;.}..vo|
|000004f0| 69 64 20 45 72 72 6f 72 | 45 78 69 74 28 63 68 61 |id Error|Exit(cha|
|00000500| 72 20 2a 73 74 72 2c 2e | 2e 2e 29 0d 7b 0d 09 63 |r *str,.|..).{..c|
|00000510| 68 61 72 20 74 62 75 66 | 5b 31 32 38 5d 3b 0d 09 |har tbuf|[128];..|
|00000520| 76 61 5f 6c 69 73 74 20 | 61 72 67 73 3b 0d 09 76 |va_list |args;..v|
|00000530| 61 5f 73 74 61 72 74 28 | 61 72 67 73 2c 73 74 72 |a_start(|args,str|
|00000540| 29 3b 0d 09 76 73 70 72 | 69 6e 74 66 28 74 62 75 |);..vspr|intf(tbu|
|00000550| 66 2c 73 74 72 2c 61 72 | 67 73 29 3b 0d 09 76 61 |f,str,ar|gs);..va|
|00000560| 5f 65 6e 64 28 61 72 67 | 73 29 3b 0d 0d 09 43 74 |_end(arg|s);...Ct|
|00000570| 6f 50 73 74 72 28 74 62 | 75 66 29 3b 0d 09 50 61 |oPstr(tb|uf);..Pa|
|00000580| 72 61 6d 54 65 78 74 28 | 28 53 74 72 69 6e 67 50 |ramText(|(StringP|
|00000590| 74 72 29 20 74 62 75 66 | 2c 22 5c 70 22 2c 22 5c |tr) tbuf|,"\p","\|
|000005a0| 70 22 2c 22 5c 70 22 29 | 3b 0d 09 41 6c 65 72 74 |p","\p")|;..Alert|
|000005b0| 28 31 32 38 2c 4e 55 4c | 4c 29 3b 0d 09 65 78 69 |(128,NUL|L);..exi|
|000005c0| 74 28 31 29 3b 0d 7d 0d | 0d 2f 2f 20 41 73 73 75 |t(1);.}.|.// Assu|
|000005d0| 6d 65 20 74 68 65 72 65 | 20 69 73 20 65 6e 6f 75 |me there| is enou|
|000005e0| 67 68 20 73 70 61 63 65 | 20 69 6e 20 73 74 72 69 |gh space| in stri|
|000005f0| 6e 67 20 74 6f 20 63 68 | 61 6e 67 65 20 69 74 0d |ng to ch|ange it.|
|00000600| 76 6f 69 64 20 43 68 61 | 6e 67 65 46 69 6c 65 45 |void Cha|ngeFileE|
|00000610| 78 74 65 6e 73 69 6f 6e | 28 53 74 72 69 6e 67 50 |xtension|(StringP|
|00000620| 74 72 20 66 4e 61 6d 65 | 2c 20 53 74 72 69 6e 67 |tr fName|, String|
|00000630| 50 74 72 20 65 78 74 29 | 0d 7b 0d 09 63 68 61 72 |Ptr ext)|.{..char|
|00000640| 20 09 2a 70 2c 2a 66 70 | 3b 0d 09 50 74 6f 43 73 | .*p,*fp|;..PtoCs|
|00000650| 74 72 28 66 4e 61 6d 65 | 29 3b 0d 09 50 74 6f 43 |tr(fName|);..PtoC|
|00000660| 73 74 72 28 65 78 74 29 | 3b 0d 09 66 70 20 3d 20 |str(ext)|;..fp = |
|00000670| 28 63 68 61 72 20 2a 29 | 20 66 4e 61 6d 65 3b 0d |(char *)| fName;.|
|00000680| 09 69 66 20 28 28 70 20 | 3d 20 73 74 72 63 68 72 |.if ((p |= strchr|
|00000690| 28 66 70 2c 27 2e 27 29 | 29 20 3d 3d 20 4e 55 4c |(fp,'.')|) == NUL|
|000006a0| 4c 29 0d 09 09 70 20 3d | 20 66 70 20 2b 20 73 74 |L)...p =| fp + st|
|000006b0| 72 6c 65 6e 28 66 70 29 | 3b 0d 09 73 74 72 63 70 |rlen(fp)|;..strcp|
|000006c0| 79 28 70 2c 28 63 68 61 | 72 20 2a 29 20 65 78 74 |y(p,(cha|r *) ext|
|000006d0| 29 3b 0d 09 43 74 6f 50 | 73 74 72 28 28 63 68 61 |);..CtoP|str((cha|
|000006e0| 72 20 2a 29 20 66 4e 61 | 6d 65 29 3b 0d 09 43 74 |r *) fNa|me);..Ct|
|000006f0| 6f 50 73 74 72 28 28 63 | 68 61 72 20 2a 29 20 65 |oPstr((c|har *) e|
|00000700| 78 74 29 3b 0d 7d 0d 0d | 73 68 6f 72 74 20 6d 69 |xt);.}..|short mi|
|00000710| 6e 28 72 65 67 69 73 74 | 65 72 20 73 68 6f 72 74 |n(regist|er short|
|00000720| 20 78 2c 20 72 65 67 69 | 73 74 65 72 20 73 68 6f | x, regi|ster sho|
|00000730| 72 74 20 79 29 0d 7b 0d | 09 69 66 20 28 78 20 3c |rt y).{.|.if (x <|
|00000740| 20 79 29 0d 09 09 72 65 | 74 75 72 6e 20 78 3b 0d | y)...re|turn x;.|
|00000750| 09 65 6c 73 65 0d 09 09 | 72 65 74 75 72 6e 20 79 |.else...|return y|
|00000760| 3b 0d 7d 0d 0d 73 68 6f | 72 74 20 6d 61 78 28 72 |;.}..sho|rt max(r|
|00000770| 65 67 69 73 74 65 72 20 | 73 68 6f 72 74 20 78 2c |egister |short x,|
|00000780| 20 72 65 67 69 73 74 65 | 72 20 73 68 6f 72 74 20 | registe|r short |
|00000790| 79 29 0d 7b 0d 09 69 66 | 20 28 78 20 3e 20 79 29 |y).{..if| (x > y)|
|000007a0| 0d 09 09 72 65 74 75 72 | 6e 20 78 3b 0d 09 65 6c |...retur|n x;..el|
|000007b0| 73 65 0d 09 09 72 65 74 | 75 72 6e 20 79 3b 0d 7d |se...ret|urn y;.}|
|000007c0| 0d 0d 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000007f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000800| 00 00 01 00 00 00 01 4c | 00 00 00 4c 00 00 00 46 |.......L|...L...F|
|00000810| a1 a7 a7 a7 d1 ad e9 e9 | e0 00 00 00 00 00 e9 fd |........|........|
|00000820| d1 ad a1 95 95 70 4b 75 | 95 a1 e6 a7 a7 e4 9b 9b |.....pKu|........|
|00000830| 0b 55 74 69 6c 46 75 6e | 63 73 2e 63 02 00 00 00 |.UtilFun|cs.c....|
|00000840| 54 45 58 54 4b 41 48 4c | 01 00 ff ff ff ff 00 00 |TEXTKAHL|........|
|00000850| 00 00 54 45 58 54 4b 41 | 48 4c 01 00 ff ff ff ff |..TEXTKA|HL......|
|00000860| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000870| 00 00 a2 49 9f 1e 00 00 | 07 42 00 00 01 92 00 ad |...I....|.B......|
|00000880| e9 ad e8 95 95 9b 9a a1 | a7 a1 95 94 9b 9b 9b a1 |........|........|
|00000890| a0 a7 a7 e7 fd ad e9 e0 | 00 00 00 00 00 00 00 e0 |........|........|
|000008a0| ad e9 ad a1 95 9a 9b a1 | a7 a0 95 71 9b 9b 9b 9b |........|...q....|
|000008b0| a1 a7 cb ad d1 e9 e9 ea | 00 00 00 00 00 00 00 ea |........|........|
|000008c0| e9 fe d1 ad 9a 9b 9b a1 | a7 a7 95 9b 9b 9b a0 a1 |........|........|
|000008d0| a7 a7 d1 ad fe d1 df 00 | 00 00 00 00 00 00 00 e0 |........|........|
|000008e0| e0 d1 fd d0 9b 95 9b a1 | a7 a7 9b 95 9b 9a a1 a1 |........|........|
|000008f0| a7 e8 fd e9 d1 fd 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000900| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 00 00 00 |...H..Mo|naco....|
|00000910| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000920| 00 00 00 00 00 00 00 06 | 00 04 00 38 00 14 01 d6 |........|...8....|
|00000930| 02 40 00 38 00 14 01 d6 | 02 40 a8 33 7b 10 00 00 |.@.8....|.@.3{...|
|00000940| 05 85 00 00 05 98 00 00 | 00 00 01 00 00 00 01 00 |........|........|
|00000950| 00 00 01 4c 00 00 00 4c | 00 00 00 46 00 82 06 30 |...L...L|...F...0|
|00000960| 17 82 00 00 00 1c 00 32 | 00 00 4d 50 53 52 00 00 |.......2|..MPSR..|
|00000970| 00 0a 03 ed 00 00 00 00 | 00 00 00 82 05 34 13 43 |........|.....4.C|
|00000980| 72 65 61 74 65 64 20 62 | 79 20 43 4d 61 73 74 65 |reated b|y CMaste|
|00000990| 72 aa 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |r.......|........|
|000009a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000009b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000009c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000009d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000009e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000009f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+